#!/usr/bin/env node

class EventEmitter{
    constructor(){
        this.#listeners = [];
    }
    on(evtName,cb){
        if(typeof this.#listeners[evtName] ==='undefined'){
            this.#listeners[evtName] = [];
        }

        this.#listeners[evtName].push(cb);
    }
    emit(evtName){
        for (let i = 0; i < this.#listeners[evtName].length; i++) {
            this.#listeners[evtName][i]();
        }
    }
    
    #listeners = null;
}

module.exports = {EventEmitter};